#!/usr/bin/env python
#encoding:utf8
import traceback


def do_exception(how="ignore", logger=None):
    def wrap(func):
        def wrap2(*args, **kwargs):
            try:
                return func(*args, **kwargs)
            except:
                if how == "ignore":
                    pass
                elif how == "logger":
                    msg = traceback.format_exc()
                    logger.error(msg)
                elif how == 'raise':
                    raise
                else:
                    raise Exception("must define one exception handler type:[ignore|logger|raise]")
            return None
        return wrap2
    return wrap


def test():
    @do_exception(how="logger", logger=)
    def func():
        raise Exception("test exception")

    func()
    print "got here"


def test_logger():
    pass



if __name__ == "__main__":
    test()
